<?php

abstract class Aggregate extends Entity implements IAggregate
{

  /**
   * (non-PHPdoc)
   * @see simplify/kernel/domain/api/IDomObj#getDefinition()
   * @return IAggregateDefinition
   */
  public function getDefinition()
  {
    return parent::getDefinition();
  }

  /**
   * (non-PHPdoc)
   * @see simplify/kernel/data/DataHolder#_del($name)
   */
  protected function _has($name)
  {
    $args = func_get_args();

    if ($this->getDefinition()->hasAssociation($name)) {
      return $this->getDefinition()->getAssociation($name)->getProxy()->hasValue($this);
    }

    return call_user_func_array(array('parent', '_has'), $args);
  }

  /**
   * (non-PHPdoc)
   * @see simplify/kernel/data/DataHolder#_del($name)
   */
  protected function _del($name)
  {
    $args = func_get_args();

    if ($this->getDefinition()->hasAssociation($name)) {
      $data = $this->getDefinition()->getAssociation($name)->getProxy()->delValue($this);
    }

    return call_user_func_array(array('parent', '_del'), $args);
  }

  /**
   * (non-PHPdoc)
   * @see simplify/kernel/data/DataHolder#_get($name)
   */
  protected function _get($name)
  {
    $args = func_get_args();

    if ($this->getDefinition()->hasAssociation($name)) {
      $data = $this->getDefinition()->getAssociation($name)->getProxy()->getValue($this);

      return $data;
    }

    return call_user_func_array(array('parent', '_get'), $args);
  }

  /**
   * (non-PHPdoc)
   * @see simplify/kernel/data/DataHolder#_set($name, $value)
   */
  protected function _set($name, $value)
  {
    $args = func_get_args();

    if ($this->getDefinition()->hasAssociation($name)) {
      return $this->getDefinition()->getAssociation($name)->getProxy()->setValue($this, $value);
    }

    return call_user_func_array(array('parent', '_set'), $args);
  }

}

?>